//
// Created by xili on 2024/9/2 13:31.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int miceAndCheese(vector<int> &reward1, vector<int> &reward2, int k) {
        int n = reward1.size();
        vector<int> v(n);
        for (int i = 0; i < n; i++) {
            v[i] = reward1[i] - reward2[i];
        }
        sort(v.begin(), v.end(), greater());
        return accumulate(reward2.begin(), reward2.end(), 0)
               + accumulate(v.begin(), v.begin() + k, 0);
    }
};
